﻿using Assets.Content.Scripts.Game;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.UI;

namespace Assets.Content.Scripts.UI.GameScene
{
    internal class PlayerInfoPanel :Widget.Widget
    {
        [SerializeField, LabelText("姓名")]
        private Text _name;

        [SerializeField, LabelText("配偶")]
        private Text _marryName;

        [SerializeField, LabelText("性别")]
        private Text _sex;

        [SerializeField, LabelText("年龄段")]
        private Text _age;

        [SerializeField, LabelText("力量值")]
        private GameObject _powerValue;

        [SerializeField, LabelText("敏捷度")]
        private GameObject _agilityValue;

        [SerializeField, LabelText("精力值")]
        private GameObject _vigorValue;

        [SerializeField, LabelText("耐力值")]
        private GameObject _enduranceValue;

        [SerializeField, LabelText("说服力")]
        private GameObject _persuasiveValue;

        [SerializeField, LabelText("建筑")]
        private GameObject _buildValue;

        [SerializeField, LabelText("制作")]
        private GameObject _createValue;

        [SerializeField, LabelText("缝纫")]
        private GameObject _sewingValue;

        [SerializeField, LabelText("科技")]
        private GameObject _technologyValue;

        [SerializeField, LabelText("医学")]
        private GameObject _medicalValue;


        protected override void Awake()
        {
            base.Awake();

            _name.text += Player.Instance.PlayerData.Name;

            _marryName.text += Player.Instance.PlayerData.Married != null
                ? Player.Instance.PlayerData.Married.Name
                : "无";

            _sex.text += Player.Instance.PlayerData.Sex;
            _age.text += Player.Instance.PlayerData.Age;

            InitAbilityValue(_powerValue, Player.Instance.PlayerData.PowerValue);
            InitAbilityValue(_agilityValue, Player.Instance.PlayerData.AgilityValue);
            InitAbilityValue(_vigorValue, Player.Instance.PlayerData.VigorValue);
            InitAbilityValue(_enduranceValue, Player.Instance.PlayerData.EnduranceValue);
            InitAbilityValue(_persuasiveValue, Player.Instance.PlayerData.PersuasiveValue);

            InitAbilityValue(_buildValue, Player.Instance.PlayerData.BuildValue);
            InitAbilityValue(_createValue, Player.Instance.PlayerData.CreateValue);
            InitAbilityValue(_sewingValue, Player.Instance.PlayerData.SewingValue);
            InitAbilityValue(_technologyValue, Player.Instance.PlayerData.TechnologyValue);
            InitAbilityValue(_medicalValue, Player.Instance.PlayerData.MedicalValue);
        }
    }
}
